<template>
  <div class="largeScreen">
    <div class="headerBox">
      <div class="frc pt30 pr20">
        <div class="flc tabsBox">
          <div class="tabsItemBg cur f14 fcc flex-1" :class="tabIdx == idx ? 'selectTabsItemBg' : ''" v-for="(item, idx) in tablist" @click="tabsFun(idx)">
            <div>{{ item.name }}</div>
            <div class="down_line"></div>
          </div>
        </div>
        <div class="fcc">
          <div class="flc ml20">
            <div class="cblue">{{ currentDate }}</div>
            <div class="cwhite ml20">{{ currentTime }}</div>
          </div>
        </div>
      </div>
    </div>

    <div class="fcbc chartBox p20">
      <div class="fcbc fv h1 flex-1 m-l-bg">
        <div class="mon-title f16 pl50 pt10">全部电场</div>
        <div class="flt flex-1 w1 pt20 pl20">
          <el-tree class="w1" :data="treeData" :props="defaultProps" @node-click="handleNodeClick" node-key="id"></el-tree>
        </div>
      </div>
      <div class="fcbc fv h1 flex-4 m-r-bg">
        <div class="videoBox w1 h1 fcc fw">
          <div class="flc flex-1 flex4 p10" v-for="(item, idx) in cameraList" :key="idx" @click="goToDetail()">
            <div class="cameraItemBor w1 h1 cur">
              <div class="cameraItemBox flex-1 h1">
                <div class="fcbc w1 cameraTitle">
                  <div class="cwhite">{{ item.name }}</div>
                </div>
                <div class="camera-time">点击查看详情</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "detection-fen",
  data() {
    return {
      // 右侧数据
      cameraList: [
        { id: 1, name: '风机#1', time: "2023-11-03 14:52:12",url:'https://www.runoob.com/try/demo_source/movie.mp4' },
        { id: 2, name: '风机#2', time: "2023-11-03 14:52:12",url:'https://www.runoob.com/try/demo_source/movie.mp4' },
        { id: 3, name: '风机#12', time: "2023-11-03 14:52:12",url:'https://www.runoob.com/try/demo_source/movie.mp4' },
        { id: 4, name: '风机#12', time: "2023-11-03 14:52:12",url:'https://www.runoob.com/try/demo_source/movie.mp4' },
        { id: 5, name: '风机#12', time: "2023-11-03 14:52:12",url:'https://www.runoob.com/try/demo_source/movie.mp4' },
        { id: 6, name: '风机#12', time: "2023-11-03 14:52:12",url:'https://www.runoob.com/try/demo_source/movie.mp4' },
        { id: 7, name: '风机#12', time: "2023-11-03 14:52:12",url:'https://www.runoob.com/try/demo_source/movie.mp4' },
        { id: 8, name: '风机#12', time: "2023-11-03 14:52:12",url:'https://www.runoob.com/try/demo_source/movie.mp4' }
      ],
      currentDate: '',
      currentTime: '',
      zoomInCenter: false,
      tabIdx: 3,
      tablist: [
        {
          name: "全景监视",
          path: "/operation",
        },
        {
          name: "监控大屏",
          path: "/monitoring",
        },
        {
          name: "驾驶舱总览",
          path: "/cockpit",
        },
        {
          name: "数据监测",
          path: "/detection",
        },
        {
          name: "智能分析",
          path: "/analysis",
        },
      ],
      videoUrl: "https://www.runoob.com/try/demo_source/movie.mp4",
      treeData: [
        {
          label: "电场#1",
          id: 1,
          children: [
            {
              label: "风机#1",
              id: 11,
            },
            {
              label: "风机#2",
              id: 12,
            },
          ],
        },
        {
          label: "电场#2",
          id: 2,
          children: [
            {
              label: "风机#1",
              id: 21,
            },
            {
              label: "风机#2",
              id: 22,
            },
          ],
        },
        {
          label: "电场#3",
          id: 3,
          children: [
            {
              label: "风机#1",
              id: 31,
            },
            {
              label: "风机#2",
              id: 32,
            },
          ],
        },
      ],
      defaultProps: {
        children: "children",
        label: "label",
      },
    };
  },
  methods: {
    // 年月日时分秒
    updateDateTime() {
      const now = new Date();

      // 格式化日期（YYYY-MM-DD 星期X）
      const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
      const year = now.getFullYear();
      const month = String(now.getMonth() + 1).padStart(2, '0');
      const day = String(now.getDate()).padStart(2, '0');
      const weekday = weekdays[now.getDay()];
      this.currentDate = `${year}-${month}-${day} ${weekday}`;

      // 格式化时间（HH:MM:SS）
      const hours = String(now.getHours()).padStart(2, '0');
      const minutes = String(now.getMinutes()).padStart(2, '0');
      const seconds = String(now.getSeconds()).padStart(2, '0');
      this.currentTime = `${hours}:${minutes}:${seconds}`;
    },
    tabsFun(i) {
      this.tabIdx = i;
      this.$router.push(this.tablist[i].path);
    },
    handleNodeClick(data) {
      // this.videoUrl = data.videoUrl
    },
    goToDetail(){
      this.$router.push({
        path:'/fengJiDetail'
      })
    }
  },
  mounted() {
    // 初始更新
    this.updateDateTime();

    // 每秒更新一次
    this.timer = setInterval(this.updateDateTime, 1000);
  },
  beforeDestroy() {
    // 清除定时器，防止内存泄漏
    clearInterval(this.timer);
  }
};
</script>

<style scoped lang="scss">
.largeScreen {
  width: 100%;
  height: 100%;
  background-color: #000f21;
  position: relative;
}
.headerBox {
  background-image: url("~@/assets/images/windPower/titleMax.png");
  background-size: 100% 100%;
  height: 84px;
  width: 100%;
  position: relative;
  z-index: 99;
  .tabsBox {
    width: 45%;
    .tabsItemBg {
      background-image: url("~@/assets/images/windPower/tabs.png");
      background-size: 100% 100%;
      height: 40px;
      color: #45a2ff;
      position: relative;
      .down_line {
        display: none;
        position: absolute;
        background-image: url("~@/assets/images/windPower/select-tabs.png");
        background-size: 100% 100%;
        width: 80%;
        height: 33px;
        top: 22px;
      }
    }
    .tabsItemBg:hover {
      color: #ffffff;
      .down_line {
        display: block;
      }
    }
    .selectTabsItemBg {
      color: #ffffff;
      .down_line {
        display: block;
      }
    }
  }
}
.cblue {
  color: #45a2ff;
}
.cwhite {
  color: #ffffff;
}
.cgray {
  color: #999999;
}
.chartBox {
  height: calc(100% - 84px);
  position: relative;
  z-index: 1;
  .chartTile {
    color: #ffffff;
    background-image: url("~@/assets/images/windPower/titleMin.png");
    background-size: 100% 100%;
    height: 40px;
    width: 100%;
    font-weight: bold;
  }
  .icon-electricity {
    color: #0aa7ff;
    background-image: url("~@/assets/images/icon/icon-electricity.png");
    background-size: 100% 100%;
    height: 50px;
    width: 50px;
  }
}
.mon-title {
  background: url("~@/assets/images/windPower/m-title.png");
  background-size: 100% 100%;
  width: 100%;
  height: 40px;
  color: #ffffff;
}
.m-l-bg {
  background: url("~@/assets/images/windPower/m-l-bg.png");
  background-size: 100% 100%;
}
.m-r-bg {
  background: url("~@/assets/images/windPower/m-bg.png");
  background-size: 100% 100%;
}
.videoBox {
  position: relative;
  padding: 35px 28px;
  .videoTitle {
    padding: 5px 10px;
    background-color: #1b7ef280;
  }
  .cameraItemBor {
    background: url("~@/assets/images/windPower/cameraBor.png");
    background-size: 100% 100%;
    padding: 10px;
  }
  .cameraItemBox {
    background: url("~@/assets/images/windPower/detectionBg2.png");
    background-size: 100% 100%;
  }
  .cameraTitle {
    background: url("~@/assets/images/windPower/cameraTitle.png");
    background-size: 100% 100%;
    padding: 5px 10px;
  }
  .flex4 {
    flex: 0 0 25%;
    height: 33.33%;
  }
  .fullScreenBox {
    position: absolute;
    top: 0;
    left: 0;
    // margin:45px 40px;
  }
}

::v-deep .el-tree {
  background: transparent;
  color: #ffffff;
}
::v-deep .el-tree-node__content:hover {
  background: linear-gradient(to right, #1b7ef2, #1b7ef200);
}
::v-deep .el-tree-node:focus > .el-tree-node__content {
  background: linear-gradient(to right, #1b7ef2, #1b7ef200);
}
::v-deep .el-carousel__container {
  height: 100%;
}
::v-deep .el-carousel__indicators {
  display: none;
}
/* 添加时间样式 */
.camera-time {
  position: absolute;
  right: 10px;
  bottom: 10px;
  color: #ffffff;
  font-size: 12px;
  background-color: transparent;
  padding: 2px 5px;
  border-radius: 3px;
}

.cameraItemBor {
  position: relative; /* 使时间定位生效 */
}
</style>
